package com.wk2un11.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.wk2un11.entity.Banner;
import com.wk2un11.util.DBManage;

public class bannerDao {

	public static ArrayList<Banner> getbanner() {
		ArrayList<Banner> list=new ArrayList<Banner>();
		try {
			Connection conn = DBManage.getConn();
			Statement st = conn.createStatement();
			String sql="SELECT * FROM banner";
			ResultSet rs = st.executeQuery(sql);
			while(rs.next()) {
				int id=rs.getInt("id");
				String title=rs.getString("title");
				String imgUrl=rs.getString("imgUrl");
				String toUrl=rs.getString("toUrl");
				Banner banner=new Banner(id, title, imgUrl, toUrl);
				list.add(banner);
			}
			DBManage.colseAll(rs, st, conn);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
}
